import type { DirectiveBinding } from "vue";
import useUserStore from "@/stores/modules/user";
export default {
  mounted(el: HTMLElement, binding: DirectiveBinding) {
    if(!Array.isArray(binding.value)){
      throw new Error(`需要配置权限，例如v-permission="['home:GET']"`)
    }
    const userStore = useUserStore();
    const hasAuth = binding.value.every(item => userStore.rulesName.includes(item));
    // 没有权限
    if(el && !hasAuth){
      el.parentNode && el.parentNode.removeChild(el);
    }
  }
}